import { _decorator, Component } from 'cc';
const { ccclass } = _decorator;

@ccclass('Singleton')
export class Singleton<T extends Component> extends Component {
    private static instance: any = null;

    public static get Instance(): any {
        return this.instance;
    }

    protected onLoad() {
        if ((this.constructor as any).instance == null) {
            (this.constructor as any).instance = this;
        } else {
            this.node.destroy();
        }
    }
}


